package com.biyu.monitormanage.model.bo;

import com.biyu.monitormanage.enums.PoliceEnums;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author 15491
 */
@Getter
public class PoliceListBo {

    /**
     * 机器id
     */
    private String machineId;

    /**
     * 短信报警
     */
    private final List<PoliceBo> msgPolice;

    /**
     * 邮件报警
     */
    private final List<PoliceBo> mailPolice;

    /**
     * 报警id
     */
    private final List<Long> idList;

    /**
     * 构造方法
     * @param machineId 机器id
     */
    public PoliceListBo(String machineId) {
        this.machineId = machineId;
        this.msgPolice = new ArrayList<>();
        this.mailPolice = new ArrayList<>();
        this.idList = new ArrayList<>();
    }

    /**
     * 添加元素
     *
     * @param type 环境参数类型
     * @param policeBo 报警对象
     * @return 是否添加成功
     */
    public boolean add(Integer type, PoliceBo policeBo, Long policeId) {
        this.idList.add(policeId);
        if (Objects.equals(type, PoliceEnums.MAIL_POLICE.getCode())) {
            this.mailPolice.add(policeBo);
            return true;
        }
        if (Objects.equals(type, PoliceEnums.MSG_POLICE.getCode())) {
            this.msgPolice.add(policeBo);
            return true;
        }
        return false;
    }

    public void setMachineId(String machineId) {
        this.machineId = machineId;
    }
}
